import request from '@/utils/request'
import { CHECC_API_CMS } from '@/constants/proxy'

// 获取列表
export function fetchListRequest(params) {
  return request({
    url: CHECC_API_CMS + '/user/getList2',
    method: 'post',
    data:params,
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: CHECC_API_CMS + '/user',
    method: 'post',
    data: data
  })
}

// 获取用户列表
export function getUserList(parms) {
  return request({
    url: CHECC_API_CMS + '/user',
    method: 'get',
    params: parms
  })
}

// 编辑用户
export function editUser(data) {
  return request({
    url: CHECC_API_CMS + '/user',
    method: 'put',
    data: data
  })
}

// 重置密码
export function restPass(id) {
  return request({
    url: CHECC_API_CMS + '/user/' + id,
    method: 'put'
  })
}

// 删除用户
export function deleteUser(id) {
  return request({
    url: CHECC_API_CMS + '/user/' + id,
    method: 'delete'
  })
}

// 获取用户个人信息
export function getUserInfo() {
  return request({
    url: CHECC_API_CMS + '/user/info',
    method: 'get'
  })
}

// 修改密码
export function updatePass(parms) {
  return request({
    url: CHECC_API_CMS + '/user/updatePass',
    method: 'put',
    params: parms
  })
}

// 修改邮箱
export function updateEmail(parms) {
  return request({
    url: CHECC_API_CMS + '/user/updateEmail',
    method: 'put',
    params: parms
  })
}

// 发送邮箱验证码
export function resetEmail(parms) {
  return request({
    url: CHECC_API_CMS + '/user/sendMailCode',
    method: 'post',
    params: parms
  })
}

// 发送短信验证码
export function sendSms(phone) {
  return request({
    url: CHECC_API_CMS + '/auth/sendCode/' + phone,
    method: 'post'
  })
}

// 绑定用户
export function bindUser(data) {
  return request({
    url: CHECC_API_CMS + '/bind',
    method: 'post',
    data: data
  })
}
// 绑定用户
export function registerUser(data) {
  return request({
    url: CHECC_API_CMS + '/register',
    method: 'post',
    data: data
  })
}

// 添加已存在的成员
export function addExitUser(data) {
  return request({
    url: CHECC_API_CMS + '/orgUser',
    method: 'post',
    data,
  })
}

// 取消用户与机构关联
export function cancelUserOrg(id) {
  return request({
    url: CHECC_API_CMS + `/user/${id}`,
    method: 'delete'
  })
}

// 获取待迁移用户列表
export function getMigrationUser(data) {
  return request({
    url: CHECC_API_CMS + '/user/getWaitMigrationUser',
    method: 'get',
    params:data,
  })
}

// 迁入用户
export function MoveIn(data) {
  return request({
    url: CHECC_API_CMS + '/user/moveInByIds',
    method: 'post',
    data,
  })
}

// 迁出用户
export function MoveOut(ids) {
  return request({
    url: CHECC_API_CMS + '/user/moveOutByIds',
    method: 'post',
    data:ids,
  })
}

// 获取AA迁入结构树
export function getdeptTree() {
  return request({
    url: CHECC_API_CMS + '/org/getAaaaOrgTreeByLU',
    method: 'get'
  })
}